package com.qxglxt.qxgl.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.qxglxt.qxgl.dao.IModulesDao;
import com.qxglxt.qxgl.model.Modules;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@ApiOperation("模块列表")
@RestController
@RequestMapping("/modules")
public class ModulesController {

   
    @Resource
    private IModulesDao modulesDao;
    @ApiOperation(value = "查询所有", notes = "分页查询")
    @PostMapping(value = "findAll")
    public Map<String, Object> findAll(){
        Map<String, Object> map = new HashMap<String, Object>();
        List<Modules> list = modulesDao.findAll();
        map.put("code", 0);
        map.put("msg", "查询出功");
        map.put("count",list.size());
        map.put("data", list);
        return map;
    }
    @ApiOperation(value = "更新用户信息", notes = "添加或修改")
    @PostMapping(value = "addOrEdit")
    public Modules saveMember(@RequestBody Modules m) {
        return modulesDao.save(m);
    }

    @ApiOperation(value = "根据id删除", notes = "根据id删除")
    @ApiImplicitParam(name = "id", value = "编号", required = true, paramType = "path")
    @DeleteMapping(value = "del")
    public void del(@PathVariable Integer id) {
         modulesDao.deleteById(id);;

    }
}